package com.mrjy.maintain.bo;

import com.mrjy.common.entity.RecordIncomeInfo;
import com.mrjy.maintain.dao.IRecordIncomeInfoDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by lyon on 2017/9/7 0007.
 */
@Service("recordIncomeInfo")
public class RecordIncomeInfoBo implements IRecordIncomeInfoBo {
    @Resource
    private IRecordIncomeInfoDao recordIncomeInfoDao;

    @Override
    public Object txInsert(RecordIncomeInfo info) {
        return recordIncomeInfoDao.insert(info);
    }

    @Override
    public int txDeleteByIds(int[] ids) {
        return recordIncomeInfoDao.deleteByIds(ids);
    }


    @Override
    public RecordIncomeInfo queryById(int id) {
        return recordIncomeInfoDao.queryById(id);
    }


    @Override
    public int txUpdateDisableFlag(RecordIncomeInfo info) {
        return recordIncomeInfoDao.updateDisableFlag(info);
    }


    @Override
    public Object queryDetailByBeneficiaryId(RecordIncomeInfo info) {
        Map map = new HashMap();
        Map map2 = recordIncomeInfoDao.queryDetailByBeneficiaryId(info);
        if (map2 != null) {
            map.put("err_code", 0);
            map.put("err_msg", "数据查询成功");
            map.put("map", map2);
        } else {
            map.put("err_code", 1);
            map.put("err_msg", "没有数据");
            map.put("map", map2);
        }
        return map;
    }

    @Override
    public Object queryIncomePageByInfo(RecordIncomeInfo info) {
        Map map = new HashMap();
        List<RecordIncomeInfo> recordIncomeInfos = recordIncomeInfoDao.queryIncomePageByInfo(info);
        if (recordIncomeInfos != null) {
            map.put("err_code", 0);
            map.put("err_msg", "数据查询成功");
            map.put("rows", recordIncomeInfos);
        } else {
            map.put("err_code", 1);
            map.put("err_msg", "没有数据");
        }
        return map;
    }


    @Override
    public List<RecordIncomeInfo> queryIncomeAll() {
        List<RecordIncomeInfo> recordIncomeInfos = recordIncomeInfoDao.queryIncomeAll();
        return recordIncomeInfos;
    }
}
